﻿Imports System.Xml.Serialization
Imports System.IO

Partial Public Class Settings
    <XmlIgnore()>
    Public Shared ReadOnly Property [Default] As Settings
        Get
            Return New Settings With {.ApiUrl = "", .InfoAddinPaths = {Path.GetFullPath(".")}, .Password = "", .ProxyPassword = "", .SenderAddinPaths = {Path.GetFullPath(".")}}
        End Get
    End Property

    Public Function AddInfoAddinPath(ByVal path As String) As Boolean
        If infoAddinPathsField.Contains(path) Then Return False
        Dim L As New List(Of String)(infoAddinPathsField)
        L.Add(path)
        infoAddinPathsField = L.ToArray
        L = Nothing
        Return True
    End Function

    Public Function RemoveFromInfoAddinPath(ByVal path As String) As Boolean
        If Not infoAddinPathsField.Contains(path) Then Return False
        Dim l As New List(Of String)(infoAddinPathsField)
        Dim b = l.Remove(path)
        infoAddinPathsField = l.ToArray
        l = Nothing
        Return b
    End Function

    Public Function AddSenderAddinPath(ByVal path As String) As Boolean
        If senderAddinPathsField.Contains(path) Then Return False
        Dim L As New List(Of String)(senderAddinPathsField)
        L.Add(path)
        senderAddinPathsField = L.ToArray
        L = Nothing
        Return True
    End Function

    Public Function RemoveFromSenderAddinPath(ByVal path As String) As Boolean
        If Not senderAddinPathsField.Contains(path) Then Return False
        Dim l As New List(Of String)(senderAddinPathsField)
        Dim b = l.Remove(path)
        senderAddinPathsField = l.ToArray
        l = Nothing
        Return b
    End Function
End Class
